  //获取用户信息，该接口需要携带token
 getUserInfo()
  function getUserInfo(){
    axios.get('/my/userinfo', {
      // headers: {
      //   Authorization: localStorage.getItem('token')
      // }
    }).then(({ data }) => {
    console.log(data);
    //  if(data.status===1&&data.message==='身份认证失败！'){
    //     return location.href='/login.html'
    //  }
      const { username, nickname, user_pic, email } = data.data
      const uname = nickname || username
      if (user_pic) {
        $('.avatar').attr('src', user_pic).show()
      } else {
        $('.text-avatar-box').show()
        $('.text-avatar').text(uname[0].toUpperCase())
      }
      // 设置欢迎
      $('#welcome').text(`你好，${uname}`)
    })
  }
 
  // 退出登录
  const layer=layui.layer
  $('#btnLogout').on('click', function () {
    layer.confirm('确认退出嘛?', {icon: 3, title:'温馨提示'}, function(index){
      //do something
      localStorage.removeItem('token')
      location.href = '/login.html'
      layer.close(index)
    })
  })